package com.soup.view.event;

import javax.swing.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

public class MouseMove implements MouseMotionListener, MouseListener {
    private JFrame win = null;
    private int beforeX,beforeY;
    public MouseMove(JFrame win) {
        this.win = win;
        this.beforeX = 0;
        this.beforeY = 0;
    }
    public void mouseDragged(MouseEvent e) {
        int afterX = e.getXOnScreen();
        int afterY = e.getYOnScreen();
        this.win.setLocation(afterX-this.beforeX, afterY-this.beforeY);
    }
    public void mouseMoved(MouseEvent e) {
    }

    public void mouseClicked(MouseEvent e) {
    }

    public void mouseEntered(MouseEvent e) {
    }

    public void mouseExited(MouseEvent e) {
    }
    public void mousePressed(MouseEvent e) {
        this.beforeX = e.getX();
        this.beforeY = e.getY();
    }
    public void mouseReleased(MouseEvent e) {
    }
}
